package cn.csust.net2.manager.shared.xml;

import java.util.HashMap;
import java.util.Map;

import cn.csust.net2.manager.client.ux.EditorType;
import cn.csust.net2.manager.shared.util.Utils;
/**
 * 对于PO显示的一些辅助信息
 * @author 韩忠金
 *
 */
public class PropertyAssist {
	public static final String NAME = "name";
	public static final String DISPLAY_NAME="displayName";
	public static final String BLANKABLE = "blankable";
	public static final String EDITOR_TYPE = "editorType";
	public static final String SIMPLEBOX = "simpleBox";
	public static final String READ_ONLY = "readOnly";
	//属性名称
	private String name;
	private boolean readOnly =false;
	//显示名称
	private String displayName;
	//是否可以为空
	private boolean blankable = true;
	//编辑器类型
	private EditorType editorType;
	//如果为本地菜单时候的值
	private String [] simpleBox;
	//承装其他属性的容器
	private Map<String,String> Properties;
	public void set(String key ,String value){
		if(key.equals(PropertyAssist.NAME)){
			this.setName(value);
		}else if(key.equals(PropertyAssist.BLANKABLE)){
			this.setBlankable(Boolean.parseBoolean(value));
		}else if(key.equals(PropertyAssist.DISPLAY_NAME)){
			this.setDisplayName(value);
		}else if(key.equals(PropertyAssist.EDITOR_TYPE)){
			this.setEditorType(EditorType.getEditorType(value));
		}else if(key.equals(PropertyAssist.SIMPLEBOX)){
			this.setSimpleBox(Utils.split(value, AssistFactory.COMMENT_SIMPLEBOX_ARRAY));
		}else if(key.equals(PropertyAssist.READ_ONLY)){
			this.setReadOnly(Boolean.valueOf(value));
		}else{
			if(Properties==null)
				Properties = new HashMap<String,String>();
			Properties.put(key, value);
		}
	}
	public String getDisplayName() {
		return displayName;
	}
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	public boolean isBlankable() {
		return blankable;
	}
	public void setBlankable(boolean blankable) {
		this.blankable = blankable;
	}
	public EditorType getEditorType() {
		return editorType;
	}
	public void setEditorType(EditorType editorType) {
		this.editorType = editorType;
	}
	public String[] getSimpleBox() {
		return simpleBox;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setSimpleBox(String[] simpleBox) {
		this.simpleBox = simpleBox;
	}
	public Map<String, String> getProperties() {
		return Properties;
	}
	public void setProperties(Map<String, String> properties) {
		Properties = properties;
	}
	public boolean isReadOnly() {
		return readOnly;
	}
	public void setReadOnly(boolean readOnly) {
		this.readOnly = readOnly;
	}
}
